package bxw.rfid_read_writerr2000.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import bxw.rfid_read_writerr2000.R;
import bxw.rfid_read_writerr2000.utils.GoodsBean;
import bxw.rfid_read_writerr2000.view.ListViewAdapter;

/**
 * @author
 * @version 1.0
 * @date 2017-12-23
 */

public class GoodsAdapter extends ListViewAdapter<GoodsBean.DataBean> {
    
    private Context mContext;
    public GoodsAdapter(Context context) {
        super(context);
        mContext = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {

        Holder holder;
        if(convertView==null){
            holder =  new Holder();
            convertView = View.inflate(mContext, R.layout.item_list_firust,null);
            holder.text_fruist = convertView.findViewById(R.id.text_fruist);
            holder.text_price = convertView.findViewById(R.id.text_price);
            holder.text_suppliername = convertView.findViewById(R.id.text_suppliername);
            convertView.setTag(holder);
        }else{
            holder = (Holder) convertView.getTag();
        }

        GoodsBean.DataBean dataBean = myList.get(position);
        holder.text_fruist.setText(dataBean.getTitle());
        holder.text_price.setText(dataBean.getPrice()+"Ԫ");
        if(!TextUtils.isEmpty(dataBean.getSuppliername())){
            holder.text_suppliername.setText(dataBean.getSuppliername());
        }

        return convertView;
    }

    class Holder{
        TextView text_fruist;
        TextView text_price;
        TextView text_suppliername;
    }
}

